﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Baza.EF.BLL;
using Baza.EF.DAL;


namespace Pep_3014_3070.Customers
{
    public partial class Owner : System.Web.UI.Page
    {
        protected int OwnerID
        {
            get { return (int)ViewState["ownerID"]; }
            set { ViewState["ownerID"] = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OwnerID = Convert.ToInt32(RouteData.Values["id"]);
                BindData();
            }
        }

        private void BindData()
        {
            List<ad_Customer_Get_Apartmans_By_OwnerID_Result> temp = DACustomers.getApartmasbyOwnerID(OwnerID);
            if (temp.Count != 0)
                lblOwner.Text = temp[0].Owner;
            else
                lblOwner.Text = "Vlasnik";
            for (int i = 0; i < temp.Count; i++)
            {
                for (int j = 0; j < temp.Count; j++)
                {
                    if(temp[i].Name == temp[j].Name)
                    {
                        temp.RemoveAt(j);
                    }
                }
            }

            ApartmasRepeater.DataSource = temp;
            ApartmasRepeater.DataBind();

        }
    }
}